import win32gui
import win32api
import win32con
import time
import pyautogui
import local_const
# from pymouse import PyMouse
hwnd_title = {}

def get_all_hwnd(hwnd, mouse):
    if (win32gui.IsWindow(hwnd) and
            win32gui.IsWindowEnabled(hwnd) and
            win32gui.IsWindowVisible(hwnd)):
        hwnd_title.update({hwnd: win32gui.GetWindowText(hwnd)})


win32gui.EnumWindows(get_all_hwnd, 0)

def getRectangle () :
    for h, t in hwnd_title.items():
        if t :
            print(h, t)
            try:
                index = -1
                index = t.index('米寒香');
            except:
                pass
            if index != -1:
                left, top, right, bottom = win32gui.GetWindowRect(h)
                return [left,top,right,bottom]
                print(left,top,right,bottom)
                # doCLick(h, 560,641)


